package com.developer.platform.domain.security;

import com.developer.platform.infrastructure.enums.LoginType;
import org.springframework.security.authentication.AbstractAuthenticationToken;

/**
 * 身份认证
 *
 * @author ：qiaoliang
 * @date ：2020-11-06
 */
public class AuthenticationInfo extends AbstractAuthenticationToken {

    private final Object principal;

    private Object credentials;

    private LoginType loginType;

    public AuthenticationInfo(Object principal, Object credentials, LoginType loginType) {
        super(null);
        this.credentials = credentials;
        this.principal = principal;
        this.loginType = loginType;
        this.setAuthenticated(false);
    }

    public AuthenticationInfo(Object principal) {
        super(null);
        this.principal = principal;
        this.setAuthenticated(true);
    }

    @Override
    public Object getPrincipal() {
        return principal;
    }

    @Override
    public Object getCredentials() {
        return credentials;
    }

    public LoginType getLoginType() {
        return loginType;
    }
}
